package com.usian.controller;

import com.usian.pojo.Etc;
import com.usian.pojo.User;
import com.usian.service.EtcService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/etc")
public class EtcController {

    @Autowired
    private EtcService etcService;

    @RequestMapping("/show")
    public String show(Model model,Etc etc){
       List<Etc> etcs =  etcService.findAll(etc);
       model.addAttribute("etcs",etcs);
       return "show";
    }
    @RequestMapping("/guan")
    public String guan(Model model,Etc etc){
       List<Etc> etcs =  etcService.findAll(etc);
       model.addAttribute("etcs",etcs);
       return "guan";
    }
    @RequestMapping("/del")
    public String del(Integer id){
       etcService.del(id);
       return "redirect:show";
    }
    @RequestMapping("/findById")
    public String findById(Integer id,Model model){
      Etc etc =etcService.findById(id);
      model.addAttribute("etc",etc);
       return "update";
    }
    @RequestMapping("/add")
    public String add(Etc etc){
       etcService.add(etc);
       return "redirect:show";
    }
    @RequestMapping("/update")
    public String update(Etc etc){
       etcService.update(etc);
       return "redirect:show";
    }
    @RequestMapping("/toadd")
    public String toadd(){
       return "add";
    }

}
